package com.bailan.utils;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;

import java.util.List;
import java.util.Optional;

public class CheckUser {

    public static  <T> T  check(IService<T> service, T user){
        List<T> list = service.list(null);
        Optional<T> first = list.stream()
                .filter(t -> t.equals(user))
                .findFirst();
        return first.orElse(null);
    }


    public static <T> T getInstance(IService<T> service){
        T t = null;
        try {
            t = service.getEntityClass().newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            e.printStackTrace();
        }
        return t;
    }


    public static <T> T getInfo(IService<T> service){
        QueryWrapper<T> queryWrapper=new QueryWrapper<T>();
//        queryWrapper.eq("");
//        service.getOne()
        return null;
    }
}
